package cz.zcu.fav.rat.rest.factory;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cz.zcu.fav.rat.beans.Object;
import cz.zcu.fav.rat.rest.beans.ObjectsMapping;
import cz.zcu.fav.rat.rest.beans.ObjectMapping;

@Component
public class ObjectsMappingFactory extends AbstractMappingFactory<ObjectsMapping, Set<Object>>
{

	@Autowired
	ObjectMappingFactory objectMappingFactory;
	
	@Override
	public ObjectsMapping getObject()
	{
		return new ObjectsMapping();
	}

	@Override
	public Class<ObjectsMapping> getObjectType()
	{
		return ObjectsMapping.class;
	}

	@Override
	public ObjectsMapping getMappedObject(Set<Object> objects)
	{
		ObjectsMapping mapping = getObject();
		List<ObjectMapping> objectMappingList = new ArrayList<ObjectMapping>();
		for (Object object : objects)
		{
			objectMappingList.add(objectMappingFactory.getMappedObject(object));
		}
		mapping.setObjects(objectMappingList);
		return mapping;
	}

	@Override
	public Set<Object> getRemappedObject(ObjectsMapping object, boolean ignoreId)
	{
		// TODO Auto-generated method stub
		return null;
	}

}
